/*
 * Copyright 2011 Dominik Pretzsch <dominik.pretzsch at gmail.com>.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * MainView.java
 *
 * Created on 12.02.2011, 20:33:29
 */

package de.blacksheep.jmoteextract.mvc.view;

import java.awt.Color;
import java.awt.Component;
import java.awt.event.ActionListener;
import java.awt.event.MouseListener;
import javax.swing.JTable;
import de.blacksheep.jmoteextract.mvc.model.JobTableModel;
import de.blacksheep.jmoteextract.filesystem.FileChooser;
import de.blacksheep.jmoteextract.mvc.model.MainModel;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JToggleButton;
import javax.swing.filechooser.FileSystemView;

/**
 *
 * @author Dominik Pretzsch <dominik.pretzsch at gmail.com>
 */
public class MainView extends javax.swing.JFrame {
    
    private MainModel _model;
    private JobTableModel localModel;
    private JobTableModel remoteModel;
    
    private String currentPath;

    /** Creates new form MainView */
    public MainView(MainModel model, 
                    JobTableModel localModel, 
                    JobTableModel remoteModel) {        
        
        this._model = model;                
        this.localModel  = localModel;
        this.remoteModel = remoteModel;        
        initComponents();
        
        // Set the background color of JScrollPanes behind
        // JTables "tableIn" and "tableOut"
        scrollTableOut.getViewport().setBackground(Color.white);
        scrollTableIn.getViewport().setBackground(Color.white);
    }
    
    // <editor-fold defaultstate="collapsed" desc="Methods For View <- Controller Interaction">
    public JTable getTableIn() {
        return tableIn;
    }
    
    public JTable getTableOut() {
        return tableOut;
    }
    
    public JMenuItem getActiveServerCheckBox() {
        return activeServerCheckBoxMenuItem;
    }
    
    public JToggleButton getActiveServerButton() {
        return activeServerButton;
    }
    
    public Object[] getDataFromConnectServerDialog() {
        Object[] data = new Object[] {
            fieldResource.getText()
        };
        return data;
    }
    
    public Object[] getDataFromCredentialsDialog() {
        Object[] data = new Object[] {
            credentialsFieldUsername.getText(), 
            String.valueOf(credentialsFieldPassword.getPassword())
        };
        return data;
    }
    
    public Object[] getDataFromExtractionDialog() {
        Object[] data = new Object[] {
            currentPath
        };
        return data;
    }
    
    public FileChooser getFileChooser(FileSystemView fsv) {
        jcifs.Config.registerSmbURLHandler();
        
        return new FileChooser(fsv) {
            /*@Override
            public void approveSelection() {
                System.out.println(getSelectedFile().getAbsolutePath());

                System.out.println((getSelectedFile().isDirectory()) ? "directory" : "no directory");
                System.out.println((getSelectedFile().isFile()) ? "file" : "no file");
                System.out.println((getSelectedFile().list() == null) ? "no listing" : "listing");
                System.out.println((getSelectedFile().exists()) ? "exists" : "does not exist");
                System.out.println((getSelectedFile().canRead()) ? "can read" : "can not read");

                //currentPath = getSelectedFile().getAbsolutePath();
                //fireActionPerformed("3");

                if (getSelectedFile().isDirectory()) {
                    return;
                } else if (!getSelectedFile().exists()) {
                    //currentPath = getSelectedFile().getAbsolutePath();
                    //fireActionPerformed("3");
                    return;
                }
                super.approveSelection();
            }*/
        };
    }
    
    public void showTableInPopup(Component cmp, int x, int y) {
        popupTableIn.show(cmp, x, y);
    }
    
    public void showTableOutPopup(Component cmp, int x, int y) {
        //popupTableOut.show(cmp, x, y);
    }
    
    public Object[] showExtractionDialog(FileSystemView fsv) {        
        FileChooser dialog = getFileChooser(fsv);

        // TODO: I18N
        dialog.setApproveButtonText("Extract");
        dialog.setDialogTitle("Extract archive...");
        dialog.setFileHidingEnabled(true);
        
        Object[] data = new Object[2];
        data[0] = dialog;
        data[1] = dialog.showOpenDialog(this);

        return data;
    }
    
    public void showCredentialsDialog(boolean visible) {
        if (visible) {
            credentialsDialog.pack();
            credentialsDialog.setLocationRelativeTo(null);
        }
        credentialsDialog.setVisible(visible);
    }
    
    public void showConnectServerDialog(boolean visible) {
        if (visible) {
            connectServerDialog.pack();
            connectServerDialog.setLocationRelativeTo(null);
        }
        connectServerDialog.setVisible(visible);
    }
    
    public void setActiveServerControlsSelected(boolean selected) {
        activeServerCheckBoxMenuItem.setSelected(selected);
        activeServerButton.setSelected(selected);
    }
    
    public void setActiveServerControlsEnabled(boolean enabled) {
        activeServerCheckBoxMenuItem.setEnabled(enabled);
        activeServerButton.setEnabled(enabled);
    }
    
    public void showMessageBox(String title, String message, int type) {
        JOptionPane.showMessageDialog(null,message,title,type);
    }
    
    public void showCredentialsFailedMessage() {
        // TODO: I18N
        String title   = "Logon failure";
        String message = "Unknown user name or bad password.";
        int type = JOptionPane.ERROR_MESSAGE;
        showMessageBox(title, message, type);
    }
    
    public void showRegisterRemoteServerFailedMessage() {
        // TODO: I18N
        String title   = "Server problem";
        String message = "Couldn't start the server.\n"
                       + "Only client mode is available.\n\n"
                       + "You can still start to extract archives\n"
                       + "on a remote server in your network, but\n"
                       + "no one will be able to extract archives\n"
                       + "on your computer.";
        int type = JOptionPane.WARNING_MESSAGE;
        showMessageBox(title, message, type);
    }
    // </editor-fold>
    
    // <editor-fold defaultstate="collapsed" desc="Register Listeners">
    public void addTableInMouseListener(MouseListener l) {
        tableIn.addMouseListener(l);
    }
    
    public void addTableOutMouseListener(MouseListener l) {
        tableOut.addMouseListener(l);
    }
    
    public void addPopupInItemActionListeners(ActionListener l) {
        TestItem.addActionListener(l);
    }
    
    public void addPopupOutItemActionListeners(ActionListener l) {
        //TestItem.addActionListener(l);
    }
    
    public void addFileMenuItemActionListeners(ActionListener l) {
        extractMenuItem.addActionListener(l);
    }
    
    public void addExtrasMenuItemActionListeners(ActionListener l) {
        settingsMenuItem.addActionListener(l);
        activeServerCheckBoxMenuItem.addActionListener(l);
    }
    
    public void addHelpMenuItemActionListeners(ActionListener l) {
        aboutMenuItem.addActionListener(l);
    }
    
    public void addActiveServerButtonActionListener(ActionListener l) {
        activeServerButton.addActionListener(l);
    }
    
    public void addCredentialsDialogActionListener(ActionListener l) {
        credentialsButtonOk.addActionListener(l);
        credentialsButtonCancel.addActionListener(l);
    }
    
    public void addConnectServerDialogActionListener(ActionListener l) {
        connectServerButtonConnect.addActionListener(l);
    }
    // </editor-fold>
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        popupTableIn = new javax.swing.JPopupMenu();
        TestItem = new javax.swing.JMenuItem();
        dialogOpen = new javax.swing.JFileChooser();
        credentialsDialog = new javax.swing.JDialog();
        credentialsFieldUsername = new javax.swing.JTextField();
        credentialsFieldPassword = new javax.swing.JPasswordField();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jSeparator3 = new javax.swing.JSeparator();
        credentialsButtonOk = new javax.swing.JButton();
        credentialsButtonCancel = new javax.swing.JButton();
        connectServerDialog = new javax.swing.JDialog();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        fieldResource = new javax.swing.JTextField();
        connectServerButtonConnect = new javax.swing.JButton();
        jLabel10 = new javax.swing.JLabel();
        jSeparator4 = new javax.swing.JSeparator();
        statusPanel = new javax.swing.JPanel();
        javax.swing.JSeparator statusPanelSeparator = new javax.swing.JSeparator();
        statusMessageLabel = new javax.swing.JLabel();
        statusAnimationLabel = new javax.swing.JLabel();
        progressBar = new javax.swing.JProgressBar();
        scrollTableOut = new javax.swing.JScrollPane();
        tableOut = new javax.swing.JTable();
        scrollTableIn = new javax.swing.JScrollPane();
        tableIn = new javax.swing.JTable();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        activeServerButton = new javax.swing.JToggleButton();
        menuBar = new javax.swing.JMenuBar();
        javax.swing.JMenu fileMenu = new javax.swing.JMenu();
        extractMenuItem = new javax.swing.JMenuItem();
        jSeparator1 = new javax.swing.JPopupMenu.Separator();
        javax.swing.JMenuItem exitMenuItem = new javax.swing.JMenuItem();
        extrasMenu = new javax.swing.JMenu();
        settingsMenuItem = new javax.swing.JMenuItem();
        jSeparator2 = new javax.swing.JPopupMenu.Separator();
        activeServerCheckBoxMenuItem = new javax.swing.JCheckBoxMenuItem();
        javax.swing.JMenu helpMenu = new javax.swing.JMenu();
        aboutMenuItem = new javax.swing.JMenuItem();

        popupTableIn.setName("popupTableIn"); // NOI18N

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(de.blacksheep.jmoteextract.JMoteExtractApp.class).getContext().getResourceMap(MainView.class);
        TestItem.setText(resourceMap.getString("TestItem.text")); // NOI18N
        TestItem.setActionCommand(resourceMap.getString("TestItem.actionCommand")); // NOI18N
        TestItem.setName("TestItem"); // NOI18N
        popupTableIn.add(TestItem);

        dialogOpen.setName("dialogOpen"); // NOI18N

        credentialsDialog.setTitle(resourceMap.getString("credentialsDialog.title")); // NOI18N
        credentialsDialog.setModalityType(java.awt.Dialog.ModalityType.APPLICATION_MODAL);
        credentialsDialog.setName("credentialsDialog"); // NOI18N
        credentialsDialog.setResizable(false);
        credentialsDialog.getRootPane().setDefaultButton(credentialsButtonOk);

        credentialsFieldUsername.setText(resourceMap.getString("credentialsFieldUsername.text")); // NOI18N
        credentialsFieldUsername.setName("credentialsFieldUsername"); // NOI18N

        credentialsFieldPassword.setText(resourceMap.getString("credentialsFieldPassword.text")); // NOI18N
        credentialsFieldPassword.setName("credentialsFieldPassword"); // NOI18N

        jLabel3.setText(resourceMap.getString("jLabel3.text")); // NOI18N
        jLabel3.setName("jLabel3"); // NOI18N

        jLabel4.setText(resourceMap.getString("jLabel4.text")); // NOI18N
        jLabel4.setName("jLabel4"); // NOI18N

        jLabel5.setText(resourceMap.getString("jLabel5.text")); // NOI18N
        jLabel5.setName("jLabel5"); // NOI18N

        jLabel8.setText(resourceMap.getString("jLabel8.text")); // NOI18N
        jLabel8.setName("jLabel8"); // NOI18N

        jSeparator3.setName("jSeparator3"); // NOI18N

        credentialsButtonOk.setText(resourceMap.getString("credentialsButtonOk.text")); // NOI18N
        credentialsButtonOk.setActionCommand(resourceMap.getString("credentialsButtonOk.actionCommand")); // NOI18N
        credentialsButtonOk.setName("credentialsButtonOk"); // NOI18N

        credentialsButtonCancel.setText(resourceMap.getString("credentialsButtonCancel.text")); // NOI18N
        credentialsButtonCancel.setActionCommand(resourceMap.getString("credentialsButtonCancel.actionCommand")); // NOI18N
        credentialsButtonCancel.setName("credentialsButtonCancel"); // NOI18N

        javax.swing.GroupLayout credentialsDialogLayout = new javax.swing.GroupLayout(credentialsDialog.getContentPane());
        credentialsDialog.getContentPane().setLayout(credentialsDialogLayout);
        credentialsDialogLayout.setHorizontalGroup(
            credentialsDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(credentialsDialogLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(credentialsDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel5)
                    .addComponent(jSeparator3, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 342, Short.MAX_VALUE)
                    .addGroup(credentialsDialogLayout.createSequentialGroup()
                        .addComponent(jLabel8)
                        .addGap(40, 40, 40))
                    .addGroup(credentialsDialogLayout.createSequentialGroup()
                        .addGap(22, 22, 22)
                        .addGroup(credentialsDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel3)
                            .addComponent(jLabel4))
                        .addGroup(credentialsDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(credentialsDialogLayout.createSequentialGroup()
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 129, Short.MAX_VALUE)
                                .addComponent(credentialsButtonOk)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(credentialsButtonCancel))
                            .addGroup(credentialsDialogLayout.createSequentialGroup()
                                .addGap(55, 55, 55)
                                .addGroup(credentialsDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(credentialsFieldPassword, javax.swing.GroupLayout.DEFAULT_SIZE, 190, Short.MAX_VALUE)
                                    .addComponent(credentialsFieldUsername, javax.swing.GroupLayout.DEFAULT_SIZE, 190, Short.MAX_VALUE))))
                        .addGap(23, 23, 23)))
                .addContainerGap())
        );
        credentialsDialogLayout.setVerticalGroup(
            credentialsDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, credentialsDialogLayout.createSequentialGroup()
                .addGap(29, 29, 29)
                .addComponent(jLabel5)
                .addGap(28, 28, 28)
                .addComponent(jSeparator3, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel8)
                .addGap(24, 24, 24)
                .addGroup(credentialsDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel3)
                    .addComponent(credentialsFieldUsername, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(12, 12, 12)
                .addGroup(credentialsDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(credentialsFieldPassword, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(8, 8, 8)
                .addGroup(credentialsDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(credentialsButtonOk)
                    .addComponent(credentialsButtonCancel))
                .addGap(23, 23, 23))
        );

        connectServerDialog.setTitle(resourceMap.getString("connectServerDialog.title")); // NOI18N
        connectServerDialog.setModalityType(java.awt.Dialog.ModalityType.APPLICATION_MODAL);
        connectServerDialog.setName("connectServerDialog"); // NOI18N
        connectServerDialog.getRootPane().setDefaultButton(connectServerButtonConnect);

        jLabel6.setText(resourceMap.getString("jLabel6.text")); // NOI18N
        jLabel6.setName("jLabel6"); // NOI18N

        jLabel7.setText(resourceMap.getString("jLabel7.text")); // NOI18N
        jLabel7.setName("jLabel7"); // NOI18N

        jLabel9.setText(resourceMap.getString("jLabel9.text")); // NOI18N
        jLabel9.setName("jLabel9"); // NOI18N

        fieldResource.setText(resourceMap.getString("fieldResource.text")); // NOI18N
        fieldResource.setName("fieldResource"); // NOI18N

        connectServerButtonConnect.setActionCommand(resourceMap.getString("connectServerButtonConnect.actionCommand")); // NOI18N
        /*
        connectServerButtonConnect.setLabel(resourceMap.getString("connectServerButtonConnect.label")); // NOI18N
        */

        connectServerButtonConnect.setText(resourceMap.getString("connectServerButtonConnect.label")); // NOI18N
        connectServerButtonConnect.setName("connectServerButtonConnect"); // NOI18N

        jLabel10.setText(resourceMap.getString("jLabel10.text")); // NOI18N
        jLabel10.setName("jLabel10"); // NOI18N

        jSeparator4.setName("jSeparator4"); // NOI18N

        javax.swing.GroupLayout connectServerDialogLayout = new javax.swing.GroupLayout(connectServerDialog.getContentPane());
        connectServerDialog.getContentPane().setLayout(connectServerDialogLayout);
        connectServerDialogLayout.setHorizontalGroup(
            connectServerDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(connectServerDialogLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(connectServerDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jSeparator4, javax.swing.GroupLayout.DEFAULT_SIZE, 334, Short.MAX_VALUE)
                    .addComponent(jLabel6)
                    .addComponent(jLabel7)
                    .addComponent(jLabel9)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, connectServerDialogLayout.createSequentialGroup()
                        .addComponent(jLabel10)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(fieldResource, javax.swing.GroupLayout.DEFAULT_SIZE, 190, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(connectServerButtonConnect)))
                .addContainerGap())
        );
        connectServerDialogLayout.setVerticalGroup(
            connectServerDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(connectServerDialogLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel6)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel7)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel9)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jSeparator4, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(connectServerDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(fieldResource, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(connectServerButtonConnect)
                    .addComponent(jLabel10))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle(resourceMap.getString("MainForm.title")); // NOI18N
        setName("MainForm"); // NOI18N
        setResizable(false);

        statusPanel.setName("statusPanel"); // NOI18N

        statusPanelSeparator.setName("statusPanelSeparator"); // NOI18N

        statusMessageLabel.setName("statusMessageLabel"); // NOI18N

        statusAnimationLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        statusAnimationLabel.setName("statusAnimationLabel"); // NOI18N

        progressBar.setName("progressBar"); // NOI18N
        progressBar.setStringPainted(true);

        javax.swing.GroupLayout statusPanelLayout = new javax.swing.GroupLayout(statusPanel);
        statusPanel.setLayout(statusPanelLayout);
        statusPanelLayout.setHorizontalGroup(
            statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(statusPanelSeparator, javax.swing.GroupLayout.DEFAULT_SIZE, 619, Short.MAX_VALUE)
            .addGroup(statusPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(statusMessageLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 449, Short.MAX_VALUE)
                .addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(statusAnimationLabel)
                .addContainerGap())
        );
        statusPanelLayout.setVerticalGroup(
            statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(statusPanelLayout.createSequentialGroup()
                .addComponent(statusPanelSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 2, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(statusMessageLabel)
                    .addComponent(statusAnimationLabel)
                    .addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(3, 3, 3))
        );

        scrollTableOut.setBackground(resourceMap.getColor("scrollTableOut.background")); // NOI18N
        scrollTableOut.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
        scrollTableOut.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
        scrollTableOut.setName("scrollTableOut"); // NOI18N

        tableOut.setModel(remoteModel);
        tableOut.setFocusable(false);
        tableOut.setName("tableOut"); // NOI18N
        scrollTableOut.setViewportView(tableOut);
        tableOut.getColumnModel().getColumn(0).setResizable(false);
        tableOut.getColumnModel().getColumn(0).setHeaderValue(resourceMap.getString("tableOut.columnModel.title0")); // NOI18N
        tableOut.getColumnModel().getColumn(1).setResizable(false);
        tableOut.getColumnModel().getColumn(1).setHeaderValue(resourceMap.getString("tableOut.columnModel.title1")); // NOI18N
        tableOut.getColumnModel().getColumn(2).setResizable(false);
        tableOut.getColumnModel().getColumn(2).setHeaderValue(resourceMap.getString("tableOut.columnModel.title2")); // NOI18N
        tableOut.getColumnModel().getColumn(2).setCellRenderer(new de.blacksheep.jmoteextract.component.ProgressRenderer());

        scrollTableIn.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
        scrollTableIn.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
        scrollTableIn.setName("scrollTableIn"); // NOI18N

        tableIn.setModel(localModel);
        tableIn.setFocusable(false);
        tableIn.setName("tableIn"); // NOI18N
        scrollTableIn.setViewportView(tableIn);
        tableIn.getColumnModel().getColumn(0).setResizable(false);
        tableIn.getColumnModel().getColumn(0).setHeaderValue(resourceMap.getString("tableOut.columnModel.title0")); // NOI18N
        tableIn.getColumnModel().getColumn(1).setResizable(false);
        tableIn.getColumnModel().getColumn(1).setHeaderValue(resourceMap.getString("tableOut.columnModel.title1")); // NOI18N
        tableIn.getColumnModel().getColumn(2).setResizable(false);
        tableIn.getColumnModel().getColumn(2).setHeaderValue(resourceMap.getString("tableOut.columnModel.title2")); // NOI18N
        tableIn.getColumnModel().getColumn(2).setCellRenderer(new de.blacksheep.jmoteextract.component.ProgressRenderer());

        jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N

        jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
        jLabel2.setName("jLabel2"); // NOI18N

        activeServerButton.setText(resourceMap.getString("activeServerButton.text")); // NOI18N
        activeServerButton.setActionCommand(resourceMap.getString("activeServerButton.actionCommand")); // NOI18N
        activeServerButton.setFocusPainted(false);
        activeServerButton.setFocusable(false);
        activeServerButton.setName("activeServerButton"); // NOI18N

        menuBar.setName("menuBar"); // NOI18N

        fileMenu.setText(resourceMap.getString("fileMenu.text")); // NOI18N
        fileMenu.setName("fileMenu"); // NOI18N

        extractMenuItem.setText(resourceMap.getString("extractMenuItem.text")); // NOI18N
        extractMenuItem.setActionCommand(resourceMap.getString("extractMenuItem.actionCommand")); // NOI18N
        extractMenuItem.setName("extractMenuItem"); // NOI18N
        fileMenu.add(extractMenuItem);

        jSeparator1.setName("jSeparator1"); // NOI18N
        fileMenu.add(jSeparator1);

        javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(de.blacksheep.jmoteextract.JMoteExtractApp.class).getContext().getActionMap(MainView.class, this);
        exitMenuItem.setAction(actionMap.get("quit")); // NOI18N
        exitMenuItem.setText(resourceMap.getString("exitMenuItem.text")); // NOI18N
        exitMenuItem.setActionCommand(resourceMap.getString("exitMenuItem.actionCommand")); // NOI18N
        exitMenuItem.setName("exitMenuItem"); // NOI18N
        fileMenu.add(exitMenuItem);

        menuBar.add(fileMenu);

        extrasMenu.setText(resourceMap.getString("extrasMenu.text")); // NOI18N
        extrasMenu.setName("extrasMenu"); // NOI18N

        settingsMenuItem.setText(resourceMap.getString("settingsMenuItem.text")); // NOI18N
        settingsMenuItem.setActionCommand(resourceMap.getString("settingsMenuItem.actionCommand")); // NOI18N
        settingsMenuItem.setName("settingsMenuItem"); // NOI18N
        extrasMenu.add(settingsMenuItem);

        jSeparator2.setName("jSeparator2"); // NOI18N
        extrasMenu.add(jSeparator2);

        activeServerCheckBoxMenuItem.setSelected(true);
        activeServerCheckBoxMenuItem.setText(resourceMap.getString("activeServerCheckBoxMenuItem.text")); // NOI18N
        activeServerCheckBoxMenuItem.setActionCommand(resourceMap.getString("activeServerCheckBoxMenuItem.actionCommand")); // NOI18N
        activeServerCheckBoxMenuItem.setName("activeServerCheckBoxMenuItem"); // NOI18N
        extrasMenu.add(activeServerCheckBoxMenuItem);

        menuBar.add(extrasMenu);

        helpMenu.setText(resourceMap.getString("helpMenu.text")); // NOI18N
        helpMenu.setName("helpMenu"); // NOI18N

        aboutMenuItem.setText(resourceMap.getString("aboutMenuItem.text")); // NOI18N
        aboutMenuItem.setActionCommand(resourceMap.getString("aboutMenuItem.actionCommand")); // NOI18N
        aboutMenuItem.setName("aboutMenuItem"); // NOI18N
        helpMenu.add(aboutMenuItem);

        menuBar.add(helpMenu);

        setJMenuBar(menuBar);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(statusPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addContainerGap(453, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 331, Short.MAX_VALUE)
                .addComponent(activeServerButton)
                .addGap(30, 30, 30))
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(scrollTableIn, javax.swing.GroupLayout.DEFAULT_SIZE, 599, Short.MAX_VALUE)
                .addContainerGap())
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(scrollTableOut, javax.swing.GroupLayout.DEFAULT_SIZE, 599, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(scrollTableOut, javax.swing.GroupLayout.PREFERRED_SIZE, 188, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(activeServerButton, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(scrollTableIn, javax.swing.GroupLayout.PREFERRED_SIZE, 188, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(statusPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    // <editor-fold defaultstate="collapsed" desc="Generated Variable Declarations">
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenuItem TestItem;
    private javax.swing.JMenuItem aboutMenuItem;
    private javax.swing.JToggleButton activeServerButton;
    private javax.swing.JCheckBoxMenuItem activeServerCheckBoxMenuItem;
    private javax.swing.JButton connectServerButtonConnect;
    private javax.swing.JDialog connectServerDialog;
    private javax.swing.JButton credentialsButtonCancel;
    private javax.swing.JButton credentialsButtonOk;
    private javax.swing.JDialog credentialsDialog;
    private javax.swing.JPasswordField credentialsFieldPassword;
    private javax.swing.JTextField credentialsFieldUsername;
    private javax.swing.JFileChooser dialogOpen;
    private javax.swing.JMenuItem extractMenuItem;
    private javax.swing.JMenu extrasMenu;
    private javax.swing.JTextField fieldResource;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPopupMenu.Separator jSeparator1;
    private javax.swing.JPopupMenu.Separator jSeparator2;
    private javax.swing.JSeparator jSeparator3;
    private javax.swing.JSeparator jSeparator4;
    private javax.swing.JMenuBar menuBar;
    private javax.swing.JPopupMenu popupTableIn;
    private javax.swing.JProgressBar progressBar;
    private javax.swing.JScrollPane scrollTableIn;
    private javax.swing.JScrollPane scrollTableOut;
    private javax.swing.JMenuItem settingsMenuItem;
    private javax.swing.JLabel statusAnimationLabel;
    private javax.swing.JLabel statusMessageLabel;
    private javax.swing.JPanel statusPanel;
    private javax.swing.JTable tableIn;
    private javax.swing.JTable tableOut;
    // End of variables declaration//GEN-END:variables
    // </editor-fold>            
}
